package com.hk.aefz.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hk.aefz.po.Comment;
import com.hk.aefz.vo.CommentAdmin;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 评论表 Mapper 接口
 * </p>
 *
 * @author 阿尔法哲
 * @since 2020-07-21
 */
public interface CommentMapper extends BaseMapper<Comment> {

    @Select("SELECT e.eid as eid,e.etitle as wztitle, c.cmcomment as wzpy,c.gmt_modified as pltime,c.aid as plid,u.uname as wzname " +
            "FROM essay e JOIN comment c JOIN user_info u " +
            "ON e.eid = c.eid and e.aid = u.aid and e.aid = #{aid} limit #{page},#{size};")
    List<CommentAdmin> selectArrayList(@Param("page")Integer page,@Param("size")Integer size,@Param("aid") int aid);

    @Select("SELECT count(1) FROM essay e JOIN comment c ON e.eid = c.eid and e.aid = #{aid};")
    Long selectCount(@Param("aid") int aid);

    @Select("SELECT count(1) FROM comment WHERE eid = #{eid};")
    int count(@Param("eid") Integer eid);
}
